package org.collector;

import java.util.Vector;

import org.collector.data.iodata.IUrl;
import org.collector.process.CoreThreadsManage;
import org.collector.process.TaskAllocRunable;
import org.collector.process.TaskFailProc;
import org.collector.process.TaskSuccessProc;
import org.workstream.ZDriver;

public class DownloadPageRun {
	private CoreThreadsManage coreThreadsManage;
	public DownloadPageRun(final String proxyPath,final int taskproc_count,final int taskalloc_count){
		coreThreadsManage = new CoreThreadsManage(proxyPath,taskproc_count,taskalloc_count);
	}
	public DownloadPageRun(final String proxyPath){
		coreThreadsManage = new CoreThreadsManage(proxyPath);
	}
	public void start(TaskFailProc taskFailProc,TaskSuccessProc taskSuccessProc){
		ZDriver.RegisterProcessNode(taskFailProc);
		ZDriver.RegisterProcessNode(taskSuccessProc);
		coreThreadsManage.start();
	}
	public void close(){
		coreThreadsManage.close();
		ZDriver.Close();
	}
	public Vector<TaskAllocRunable> getVct_taskAllocs() {
		return coreThreadsManage.getVct_taskAllocs();
	}
	public boolean addTask(IUrl url){
		return coreThreadsManage.addTask(url);
	}
	public int getTaskCount(){
		return coreThreadsManage.getClientsWithStatu().getTotalQueueLen();
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
